﻿using Abp.EntityFrameworkCore;
using Abp.Modules;
using Abp.Reflection.Extensions;
using Batman.Cms.Core;
using Batman.IdentityServer.Extension;
using Microsoft.Extensions.Configuration;

namespace Batman.Identity.Startups
{
    [DependsOn(
        typeof(AbpEntityFrameworkCoreModule),
        //typeof(AbpAutoMapperModule),
        typeof(BatmanCoreModule),
        typeof(BatmanIdentityServerModule)
        )]
    public class BatmanIdentityModule : AbpModule
    {
        private IConfiguration AspNetConfiguration;

        public BatmanIdentityModule(IConfiguration configuration)
        {
            AspNetConfiguration = configuration;
        }

        public override void PreInitialize()
        {
            var connectionString = AspNetConfiguration.GetConnectionString("DefaultConnection");
            //Configuration.Modules.AbpEfCore().AddDbContext<BatmanIdentityDbContext>(options =>
            //{
            //    options.DbContextOptions.UseMySql(connectionString);
            //});

            //Configuration.Modules.AbpEfCore().AddDbContext<ConfigurationDbContext>(options =>
            //{
            //    options.DbContextOptions.UseMySql(connectionString);
            //});
        }

        public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(typeof(BatmanIdentityModule).GetAssembly());
            IocManager.RegisterAssemblyByConvention(typeof(IdentityServer4.IdentityServerUser).GetAssembly());
        }
    }
}
